How do I Create a list of enumerations used in a module

Hi,
I have a module with a multi-value enumberation attribute type which contains names. I am trying to get a list of all the discrete values used in the module (both single and multi-value)used and assign them to an array.

Can anyone help please?

Thanks

Chris
Stig0498 - Thu Mar 10 06:27:59 EST 2011

Re: How do I Create a list of enumerations used in a module
bullbala - Thu Mar 10 07:12:37 EST 2011

Here is a script I found in the Net and I am unable to recall the name of its author.
It may meet your needs.
 

string results = ""
AttrType at
 
atCount = 0
int tmp = 0, cnt = 0
 
for at in current Module do 
{
    if (! at.system)
    { 
        results = results at.name " : " (at.type) "\n\n"
                if ((at.type "" == "Enumeration") && (atCount == 0))
                {
                        atCount++
                }
        
                atCount = 0
                tmp = at.size
        
                for (cnt = 0;cnt < tmp;cnt=(cnt + 1))
                {
                        results = results "\t" cnt "  " at.strings[cnt] "\n"
                }
        
                results = results "\n"
                print results
    } //End of if
}

Re: How do I Create a list of enumerations used in a module
Stig0498 - Thu Mar 10 09:03:39 EST 2011

bullbala - Thu Mar 10 07:12:37 EST 2011

Here is a script I found in the Net and I am unable to recall the name of its author.
It may meet your needs.
 

string results = ""
AttrType at
 
atCount = 0
int tmp = 0, cnt = 0
 
for at in current Module do 
{
    if (! at.system)
    { 
        results = results at.name " : " (at.type) "\n\n"
                if ((at.type "" == "Enumeration") && (atCount == 0))
                {
                        atCount++
                }
        
                atCount = 0
                tmp = at.size
        
                for (cnt = 0;cnt < tmp;cnt=(cnt + 1))
                {
                        results = results "\t" cnt "  " at.strings[cnt] "\n"
                }
        
                results = results "\n"
                print results
    } //End of if
}

Thanks for the reply,

I am look at finding the values that have actually been assigned against objects as opposed to the list of available enumerators e.g.

Obj1 Bob, Jim

Obj2 Jim

Obj3 Peter, Gary

Obj4 Jim

Obj5 Bob, Jim

The results I want are:
1) Bob, Jim
2) Jim
3) Peter, Gary

Re: How do I Create a list of enumerations used in a module
bullbala - Thu Mar 10 10:09:45 EST 2011

Stig0498 - Thu Mar 10 09:03:39 EST 2011
Thanks for the reply,

I am look at finding the values that have actually been assigned against objects as opposed to the list of available enumerators e.g.

Obj1 Bob, Jim

Obj2 Jim

Obj3 Peter, Gary

Obj4 Jim

Obj5 Bob, Jim

The results I want are:
1) Bob, Jim
2) Jim
3) Peter, Gary

I hope this example (again borrowed from the Net and edited) might be what you are looking for :-)
Replace "Attribute 1" with the name of your attribute.
 

// prevent dxl timeout dialog 
pragma runLim, 0
 
Skip split ( string s, char c )
{    
    Skip split_string = create 
        int deb = 0
        int i
        int index = 0 
        
        for ( i=0; i<length(s)-1; i++ )
        { 
                if ( s[i] != c )
                        continue 
                
                put( split_string, index, s[deb:i-1] ) 
                deb = i+1
                index += 1 
        } 
        
        if ( s[i] == c )
                i-- 
        
        put ( split_string, index, s[deb:i] ) 
        
        return split_string 
} 
 
string attrVal = null
bool isFirstValue = true
 
Skip theSplitString = create
string tmp 
 
Object o
 
// Loop through the current display set.
for o in current Module do
{
        attrVal = probeAttr_(o, "Attribute 1")
        theSplitString = split ( attrVal, '\n' )
        isFirstValue = true
 
        print identifier o " : " 
                
        for tmp in theSplitString do
        {
                if(isFirstValue)
                {
                        isFirstValue = false
                        print tmp
                }
                else
                        print ", " tmp 
        }
        
        print "\n"
}
 
delete theSplitString

Re: How do I Create a list of enumerations used in a module
llandale - Thu Mar 10 14:32:15 EST 2011

Browsed the other responses. You usually count the enumerations, declare the array at that size, then loop through the enumerations again setting the values.

You can use the "isMember" perm to determine if a particular object has the enumeration set, e.g.

if (isMember(obj."MyEnumAttr", "Borneo")) then deal with Borneo object

  • Louie

Re: How do I Create a list of enumerations used in a module
Stig0498 - Mon Mar 14 05:20:44 EDT 2011

llandale - Thu Mar 10 14:32:15 EST 2011
Browsed the other responses. You usually count the enumerations, declare the array at that size, then loop through the enumerations again setting the values.

You can use the "isMember" perm to determine if a particular object has the enumeration set, e.g.

if (isMember(obj."MyEnumAttr", "Borneo")) then deal with Borneo object

  • Louie

Hi,

I don't think I explained properly what I was trying to do. I am trying to get a list of unigue values / combination of values used in the module.

This will not be equal to the number of enumerations. In the example below, the enumerated list is Bob, Jim, Peter, Gary. The list I need to generate is a list of unique permutations used in the module, i.e. 1)Bob, Jim 2) Jim 3) Peter, Gary. All duplicate entries to be ignored

Obj1 Bob, Jim

Obj2 Jim

Obj3 Peter, Gary

Obj4 Jim

Obj5 Bob, Jim

The results I want are:
1) Bob, Jim
2) Jim
3) Peter, Gary

Re: How do I Create a list of enumerations used in a module
bullbala - Mon Mar 14 05:53:14 EDT 2011

Stig0498 - Mon Mar 14 05:20:44 EDT 2011
Hi,

I don't think I explained properly what I was trying to do. I am trying to get a list of unigue values / combination of values used in the module.

This will not be equal to the number of enumerations. In the example below, the enumerated list is Bob, Jim, Peter, Gary. The list I need to generate is a list of unique permutations used in the module, i.e. 1)Bob, Jim 2) Jim 3) Peter, Gary. All duplicate entries to be ignored

Obj1 Bob, Jim

Obj2 Jim

Obj3 Peter, Gary

Obj4 Jim

Obj5 Bob, Jim

The results I want are:
1) Bob, Jim
2) Jim
3) Peter, Gary

I think I understand your requirement better now.
Generally, skip lists are used to create lists without duplicates.

Is the following script what you were looking for ?
 

// Create list of unique permutations in alphabetical order.
Skip uniquePermutations = createString
 
Object o
 
// Loop through the display set of the current module.
for o in current Module do
{
    put(uniquePermutations, o."Attribute 1" "", o."Attribute 1" "")
}
 
string temp
int count = 0
 
// Loop through the list of unique permutations.
for temp in uniquePermutations do
{
        count++
        print (count) ")" temp "\n"
}
 
// Free memory.
delete uniquePermutations

 


Note: Replace "Attribute 1" with the name of your attribute.

 

Re: How do I Create a list of enumerations used in a module
Stig0498 - Mon Mar 14 06:37:08 EDT 2011

bullbala - Mon Mar 14 05:53:14 EDT 2011

I think I understand your requirement better now.
Generally, skip lists are used to create lists without duplicates.

Is the following script what you were looking for ?
 

// Create list of unique permutations in alphabetical order.
Skip uniquePermutations = createString
 
Object o
 
// Loop through the display set of the current module.
for o in current Module do
{
    put(uniquePermutations, o."Attribute 1" "", o."Attribute 1" "")
}
 
string temp
int count = 0
 
// Loop through the list of unique permutations.
for temp in uniquePermutations do
{
        count++
        print (count) ")" temp "\n"
}
 
// Free memory.
delete uniquePermutations

 


Note: Replace "Attribute 1" with the name of your attribute.

 

perfect! Thanks for the help.